var getNumberList = function () {
  var sqlParams = new Object();
  sqlParams.uuid = Params.uuid;
  sqlParams.page = Params.page;
  sqlParams.size = Params.size;
  sqlParams.is_valid = Params.is_valid;
  sqlParams.create_time_start = Params.create_time_start;
  sqlParams.create_time_end = Params.create_time_end;
  sqlParams.res = Params.res;
  var is_valid = Params.is_valid;
  var create_time_start = Params.create_time_start;
  var create_time_end = Params.create_time_end;
  var page = Params.page;
  var res = Params.res;
  sqlParams.pageNumber = page * (Params.size);
  var sql1 = "select a.uuid,b.*,c.name,c.permission from app_open_api_c002_callout_user_verify_2 a left join app_open_api_c003_hbdh_user_1 b on a.user_id=b.id  left join app_open_api_c001_hbdh_role_1 c on b.role_id=c.id where a.uuid=#{uuid}";
  var result1 = JSON.parse(CustomizeUtil.abilitySql(sql1, sqlParams));
  if (result1.data.count > 0) {
    // 日志记录
    sqlParams.username = result1.data.results[0].username
    var sql_log = "insert into app_open_api_c001_zhyd_log_6(phone,create_time,method) values(#{username},now(),'getNumberList')";
    CustomizeUtil.abilitySql(sql_log, sqlParams);
    if (result1.data.results[0].permission == 'admin') {
      // 查询全量号码
      var sql_total = "select a.*, b.chnl_name,b.nick_name from app_open_api_c003_hbdh_number_1 a left join app_open_api_c003_hbdh_user_1 b on a.creator = b.username where 1=1 ";
      if (is_valid !== 'null') {
        sql_total = sql_total + " and a.is_valid = #{is_valid}";
      }
      if (res !== 'null') {
        sql_total = sql_total + " and a.res = #{res}";
      }
      if (create_time_start !== 'null' && create_time_end !== 'null') {
        sql_total = sql_total + " and a.create_time between #{create_time_start} and #{create_time_end}";
      }
      sql_total = sql_total + " order by create_time desc limit #{pageNumber},#{size}";
      var result = JSON.parse(CustomizeUtil.abilitySql(sql_total, sqlParams));
      var sql3 = "select count(1) cnt from app_open_api_c003_hbdh_number_1 where 1=1 ";
      if (is_valid !== 'null') {
        sql3 = sql3 + " and is_valid = #{is_valid}";
      }
      if (res !== 'null') {
        sql3 = sql3 + " and res = #{res}";
      }
      if (create_time_start !== 'null' && create_time_end !== 'null') {
        sql3 = sql3 + " and create_time between #{create_time_start} and #{create_time_end}";
      }
      var result3 = JSON.parse(CustomizeUtil.abilitySql(sql3, sqlParams));
      result.data.count = result3.data.results[0].cnt;
      JsResult.result = JSON.stringify(result);
    } else {
      // 查询用户名下号码
      var sql_current = "select a.*, b.chnl_name,b.nick_name from app_open_api_c003_hbdh_number_1 a left join app_open_api_c003_hbdh_user_1 b on a.creator = b.username where 1=1 and a.creator = #{username}  ";
      if (is_valid !== 'null') {
        sql_current = sql_current + " and a.is_valid = #{is_valid}";
      }
      if (res !== 'null') {
        sql_current = sql_current + " and a.res = #{res}";
      }
      if (create_time_start !== 'null' && create_time_end !== 'null') {
        sql_current = sql_current + " and a.create_time between #{create_time_start} and #{create_time_end}";
      }
      sql_current = sql_current + " order by create_time desc limit #{pageNumber},#{size}";
      var result = JSON.parse(CustomizeUtil.abilitySql(sql_current, sqlParams));
      var sql3 = "select count(1) cnt from app_open_api_c003_hbdh_number_1  where creator = #{username} ";
      if (is_valid !== 'null') {
        sql3 = sql3 + " and is_valid = #{is_valid}";
      }
      if (res !== 'null') {
        sql3 = sql3 + " and res = #{res}";
      }
      if (create_time_start !== 'null' && create_time_end !== 'null') {
        sql3 = sql3 + " and create_time between #{create_time_start} and #{create_time_end}";
      }
      var result3 = JSON.parse(CustomizeUtil.abilitySql(sql3, sqlParams));
      result.data.count = result3.data.results[0].cnt;
      JsResult.result = JSON.stringify(result);
    }

  } else {
    var result2 = "{'data':{'count':1,'results':'登录失效','status':1},'publicData':{'retInfo':{'retType':1,'retCode':0,'retMsg':'登录失效，请先登录'}}}";
    JsResult.result = result2;
  }
};
getNumberList();
